package com.cdtye.itps.cms.service.categoryreport;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.cdtye.common.mybatiscore.base.BaseService;
import com.cdtye.itps.cms.dao.categoryreport.entity.JcjcCategoryReport;
import com.cdtye.itps.cms.dao.categoryreport.vo.JcjcCategoryReportVo;
import com.cdtye.itps.cms.mapper.categoryreport.JcjcCategoryReportMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;
import java.util.Map;

/**
 * 1c超限数据-缺陷报表 服务类
 * @author Jchen
 * @date 2021-09-24
 */
@Service
public class JcjcCategoryReportService extends BaseService<JcjcCategoryReportMapper, JcjcCategoryReport> {

    @Autowired
    private JcjcCategoryReportMapper modelMapper;

    /**
     * 分页查询，自定义sql语句
     * @param vo
     * @return
     */
    public IPage<Map<String,Object>> listPage(JcjcCategoryReportVo vo){
        return modelMapper.list(vo.page(), vo);
    }

    public JcjcCategoryReport queryByParams(String lineId, String directionId, Date taskDate, String mileage, String categoryId, String levelId){
        QueryWrapper<JcjcCategoryReport> wrapper = new QueryWrapper();
        wrapper.eq("line_id",lineId);
        wrapper.eq("direction_id",directionId);
        wrapper.eq("task_date",taskDate);
        wrapper.eq("mileage",mileage);
        wrapper.eq("LEVEL_ID",levelId);
        wrapper.eq("CATEGORY_ID",categoryId);
        List<JcjcCategoryReport> list = modelMapper.selectList(wrapper);
        if (list!=null && list.size()>0) {
            return list.get(0);
        }else {
            return null;
        }
    }

}
